<template>
  <div class="wrapper">
    <div
      class="hotInforWrapper"
      v-for="item in dataList"
      :key="item.id"
      @click="toDetai(item.id)"
    >
      <img
        :src="imgBaseUrl+item.imgUrl"
        class="pic"
      >
      <div class="content">
        <p class="title">{{item.title}}</p>
        <p class="timer">{{item.createTime}}</p>
      </div>
    </div>
    <div
      class="noDataWrap"
      v-if="kong"
    >
      <noData />
      <p class="noDataContent">敬请期待</p>
    </div>
  </div>
</template>
<script>
import noData from '@/components/noData/nodata';
import { imgBaseUrl } from '@/config/env.js';
export default {
  data() {
    return {
      kong: false,
      dataList: {},
      imgBaseUrl
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    // 去详情
    toDetai(id) {
      this.$router.push({
        path: '/hotDetail',
        query: { id: id }
      });
    },

    // 获取数据
    getData() {
      this.$http
        .post('/news/list', { pageNum: '0', pageSize: '500' })
        .then(res => {
          console.log(res);
          if (res && res.data.list.length > 0) {
            this.dataList = res.data.list;
            console.log(this.dataList);
          } else {
            this.kong = true;
          }
        });
    }
  },
  components: {
    noData
  }
};
</script>
<style lang="scss" scoped>
.wrapper {
  background-color: #ffffff;
}
.hotInforWrapper {
  display: flex;
  justify-content: center;
  height: 2.666667rem;
  border-bottom: 1px solid #ebedf0;
  align-items: center;
  margin: 0 0.4rem;
  .pic {
    width: 2.53rem;
    height: 1.73rem;
    margin-right: 0.4rem;
  }
  .content {
    .title {
      font-size: 0.4rem;
      color: #222c38;
      // margin-bottom: 0.61rem;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }
    .timer {
      font-size: 0.27rem;
      color: #a9afb5;
      padding-top: 0.3rem;
    }
  }
}
.noDataWrap {
  padding-top: 4rem;
}
.noDataContent {
  text-align: center;
  font-size: 0.43rem;
  color: #868688;
}
</style>